package com.woniuxy.power.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.power.core.mapper.YdPowerMapper;
import com.woniuxy.power.core.model.YdPower;
import com.woniuxy.power.core.model.YdStation;
import com.woniuxy.power.core.service.YdPowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-06-29
 */
@Api(tags = "油电店铺相关接口")
@RestController
@RequestMapping("/ydPower")
public class YdPowerController {
    @Resource
    private YdPowerMapper YdPower;

    @Resource
    private YdPowerService ydPowerService;


    /**
     * Description : 查询所有油电店铺  <br/>
     * ChangeLog : 1. 创建 (2021/7/2 16:05 [Hello Mr. Guo]);
     *
     * @return com.woniuxy.common.CommonResult
    */
    @ApiOperation("查询所有油电店铺")
    @GetMapping("/selectAll")
    public CommonResult selectAll(){
        List<YdPower> ydPowers = this.ydPowerService.list();
        return CommonResult.success(ydPowers);
    }


    @ApiOperation("查询单个油电店铺")
    @GetMapping("/selectOne/{id}")
    public CommonResult selectOne(@PathVariable("id") Integer id){
        YdPower ydPowers = this.YdPower.selectById(id);
        return CommonResult.success(ydPowers);
    }

    @ApiOperation("查询一个油电店铺的电桩")
    @GetMapping("/selectByStation/{powerId}")
    public CommonResult selectByStation(@PathVariable("powerId") int powerId){
        List<YdStation> station = this.ydPowerService.selectByStation(powerId);
        return CommonResult.success(station);
    }



}

